﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class Mondriaan
    {
        public Mondriaan()
        {
            int testCase = GetConsole.GetInt();
            while (testCase-- > 0)
            {
                int x = GetConsole.GetInt();
                int y = GetConsole.GetInt();
                if (x == 0 || y == 0)
                {
                    Console.WriteLine("0");
                    continue;
                }
                if (x % 2 != 0)
                {
                    if (y % 2 != 0)
                    {
                        Console.WriteLine("0");
                        continue;
                    }
                    else //x가 짝수가 되게 변경
                    {
                        int buf = y;
                        y = x;
                        x = buf;
                    }
                }
                if (y == 1)
                {
                    Console.WriteLine("1");
                    continue;
                }
                //(x,2) 크기의 값 계산
                int unitValue = 0;
                if (x == 2)
                {
                    unitValue = 2;
                }
                int a = 1;
                int b = 2;
                for (int i = 3; i < x; i++)
                {
                    unitValue = a + b;
                    a = b;
                    b = unitValue;
                    Console.WriteLine(unitValue);
                }
                int totalValue = 0;
                int totalA = unitValue;
                int totalB = unitValue * 2 - 1;
                for (int i = 3; i < y; i++)
                {
                    totalValue = (totalA * unitValue) + totalB - totalA;
                    totalA = totalB;
                    totalB = totalValue;
                }
                Console.WriteLine(totalValue);
            }
        }
    }

}
